package com.aaa.service.impl;

import com.aaa.dao.ChangeMoneyDao;
import com.aaa.pojo.BankNumber;
import com.aaa.pojo.ChangeMoney;
import com.aaa.service.ChangeMoneyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class ChangeMoneyServiceImpl implements ChangeMoneyService {
    @Autowired
    private ChangeMoneyDao changeMoneyDao;


    @Override
    public PageInfo<ChangeMoney> getChangeByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);//这行是重点，表示从pageNum页开始，每页pageSize条数据
        List<ChangeMoney> list = changeMoneyDao.selectAllMoneys();
        PageInfo<ChangeMoney> pageInfo = new PageInfo<ChangeMoney>(list);
        return pageInfo;
    }

    @Override
    public ChangeMoney selectById(Integer c_id) {
        return changeMoneyDao.selectByCid(c_id);
    }

    @Override
    public List<String> getChangeColumn() {
       // return changeMoneyDao.getChangeColumn();
        return null;
    }

    @Override
    public Boolean addChangeMoney(Integer u_id,Integer c_id,Double amount) {
        return changeMoneyDao.addChangeMoney(u_id,c_id,amount);
    }

    @Override
    public void addRecordMoney(Double amount, String c_name) {
        changeMoneyDao.addRecordMoney(amount, c_name);
    }

    @Override
    public List<BankNumber> selectByBid(Integer uid) {
        return changeMoneyDao.selectByBid(uid);
    }

    @Override
    public Boolean deductionBank(Integer bank_id, Double money) {
        return changeMoneyDao.deductionBank(bank_id, money);
    }
}
